/** 
* @param {array}
* @param {number}
* @param {number}
* @returns {array}
**/
function slice(array, start = 0, end = array.length) {
  if (start < 0) {
    start = Math.max(array.length + start, 0)
  }
  if (end < 0) {
    end = Math.min(array.length + end, array.length)
  }

  const size = end - start

  if (size < 0) return []

  const res = new Array(size)
  let i = -1

  while (++i < size) {
    res[i] = array[i + start]
  }
  return res
}

export default slice